import {httpRequest} from '@/utils/http';
import {ElevatorRepairVO, ElevatorRepairForm, ElevatorRepairQuery} from '@/api/iot/elevatorRepair/types';

enum Api {
    root = '/iot/elevatorRepair',
    list = '/iot/elevatorRepair/list',
    startRepair = '/iot/elevatorRepair/startRepair',
    reportFault = '/iot/elevatorRepair/report',
    submitElevatorRepair = '/iot/elevatorRepair/submitElevatorRepair',
    marchElevatorRepair = '/iot/elevatorRepair/marchElevatorRepair'
}

/**
 * 查询电梯维修列表
 * @param query
 * @returns {*}
 */
export function listElevatorRepair(query?: ElevatorRepairQuery) {
    return httpRequest.get<ElevatorRepairVO[]>({url: Api.list, data: query});
}

/**
 * 查询电梯维修详细
 * @param repairId
 */
export function getElevatorRepair(repairId: string | number) {
    return httpRequest.get<ElevatorRepairVO>({url: Api.root + '/' + repairId});
}

/**
 * 新增电梯维修
 * @param data
 */
export function addElevatorRepair(data: ElevatorRepairForm) {
    return httpRequest.post({url: Api.root, data});
}

/**
 * 修改电梯维修
 * @param data
 */
export function updateElevatorRepair(data: ElevatorRepairForm) {
    return httpRequest.put({url: Api.root, data});
}

/**
 * 删除电梯维修
 * @param repairId
 */
export function deleteElevatorRepair(repairId: string | number) {
    return httpRequest.delete({url: Api.root + '/' + repairId});
}

/**
 * 接受维修接口
 */
export function startRepair(data: any) {
    return httpRequest.put({url: Api.startRepair , data});
}

/**
 * 提交维修
 */
export function submitElevatorRepair(data: any) {
    return httpRequest.put({url: Api.submitElevatorRepair, data});
}

/**
 * 开始维修
 */
export function marchElevatorRepair(data: any) {
    return httpRequest.put({url: Api.marchElevatorRepair, data});
}

/**
 * 上报故障
 */
export function reportFault(data: any) {
    return httpRequest.post({url: Api.reportFault, data});
}

